package com.dance.spring.learn.jdbc.dao.impl;

import com.dance.spring.learn.jdbc.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class UserDaoImpl implements UserDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public void add() {
        int dance = jdbcTemplate.update("update account set meony=meony+? where username = ?", 100, "dance");
        System.out.println("转账完成,dance 账户到账100元");
    }

    @Override
    public void reduce() {
        int dance = jdbcTemplate.update("update account set meony=meony-? where username = ?", 100, "flower");
        System.out.println("转账完成,flower 账户支出100元");
    }
}
